package com.yuxi.shuzu;

public class Demo6 {
    public static void main(String[] args) {

        int wu = getWuhui();
        int qi = getQihui();
        System.out.println("wu = " + wu);
        System.out.println("qi = " + qi);
        int cha = wu-qi;
        if (cha<0){
            cha = cha*(-1);
        }
        System.out.println("相差"+cha);

    }

    private static int getQihui() {
        int count = 0;
        for (int i = 1000000; i < 10000000; i++) {
            int baiwan = i/1000000;
            int shiwan = i%1000000/100000;
            int wan = i%100000/10000;
            int qian = i%10000/1000;
            int bai = i%1000/100;
            int shi = i%100/10;
            int ge = i%10;
            if (ge==baiwan&&shi==shiwan&&bai==wan){
                count++;
            }
        }
        return count;
    }

    private static int getWuhui() {
        int count = 0;
        for (int i = 10000; i < 100000; i++) {
            int wan = i/10000;
            int qian = i%10000/1000;
            int bai = i%1000/100;
            int shi = i%100/10;
            int ge = i%10;
            if (ge==wan&&shi==qian){

                count++;
            }
        }
        return count;
    }
}
